#ifndef RESERVATIONEDITDIALOG_H
#define RESERVATIONEDITDIALOG_H

#include <QDialog>
#include <QList>

#include "../../Headers/Classes/typeofroom.h"
#include "../../Headers/DataAccessors/typeofroomdataaccessor.h"
#include "../../Headers/Classes/client.h"
#include "../../Headers/DataAccessors/clientdataaccessor.h"
#include "../../Headers/DataAccessors/advancedoptiondataaccessor.h"
#include "../../Headers/DataAccessors/roomdataaccessor.h"
#include "../../Headers/Classes/myutils.h"
#include "../../Headers/UI/typeofroomdialog.h"
#include "../../Headers/UI/clientsdialog.h"
#include "../../Headers/UI/clientchoosedialog.h"
#include "../../Headers/UI/advanceoptionsdialog.h"
#include "../../Headers/DataAccessors/reservationdataaccessor.h"

namespace Ui {
    class ReservationEditDialog;
}

class ReservationEditDialog : public QDialog
{
    Q_OBJECT

    TypeOfRoom *typeOfRoom;
    Client *client;
    Room *room;

    MyUtils::FormStatus formStatus;
    Reservation *reservation;

    QList<AdvancedOption*> options;

public:
    explicit ReservationEditDialog(MyUtils::FormStatus formStatus = MyUtils::Adding, Reservation *reservation = NULL, QWidget *parent = 0);
    ~ReservationEditDialog();

    void loadTypeOfRooms();
    void loadClient();
    void loadAdvancedOptions();
    void loadRoom();
    void loadAddedAdvancedOptions();

    void updateResult();
    void finish();
    void chooseRoom();
    int countDays();
    void countCost();

    void nullClient();
    bool check();

    TypeOfRoom * getCurrentTypeOfRoom();
    Room * getCurrentRoom();
    AdvancedOption * getCurrentAdvancedOption();

private slots:
    void on_nextPagePushButton_clicked();

    void on_previousPagePushButton_clicked();

    void on_typeOfRoomBrowsePushButton_clicked();

    void on_clientBrowsePushButton_clicked();

    void on_typeOfRoomComboBox_currentIndexChanged(int index);

    void on_optionBrowsePushButton_clicked();

    void on_listView_activated(const QModelIndex &index);

    void on_firstNameLineEdit_editingFinished();

    void on_lastNameLineEdit_editingFinished();

    void on_documentLineEdit_editingFinished();

    void on_phoneLineEdit_editingFinished();

    void on_searchRoomPushButton_clicked();

    void on_chooseRoomButton_clicked();

    void on_addOptionPushButton_clicked();

    void on_listView_clicked(const QModelIndex &index);

    void on_deleteOptionPushButton_clicked();

private:
    Ui::ReservationEditDialog *ui;
};

#endif // RESERVATIONEDITDIALOG_H
